
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 17/11/2013 20:29:50
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class OrderDetail
    /// </summary>
    [Serializable]
    public partial class OrderDetail : _DomainLayer_Base  
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual int Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FK_Order.
        /// </summary>
        /// <value>The FK_Order.</value>
        /// <remarks>
        /// Foregn key of OrderDetail
        /// 
        /// </remarks>
        public virtual int FK_Order
        {
            get { return _fK_Order; }
            set
            {
                if (_fK_Order != value)
                {
                    if (Order != null && Order.Id != value)
                    {
                        Order = null;
                    }
                    _fK_Order = value;
                }
            }
        }
        private int _fK_Order;
    	
        /// <summary>
        /// Gets or sets FK_Product.
        /// </summary>
        /// <value>The FK_Product.</value>
        /// <remarks>
        /// Foregn key of OrderDetail
        /// 
        /// </remarks>
        public virtual int FK_Product
        {
            get { return _fK_Product; }
            set
            {
                if (_fK_Product != value)
                {
                    if (Product != null && Product.Id != value)
                    {
                        Product = null;
                    }
                    _fK_Product = value;
                }
            }
        }
        private int _fK_Product;
    	
        /// <summary>
        /// Gets or sets ProductDescription.
        /// </summary>
        /// <value>The ProductDescription.</value>
        public virtual string ProductDescription
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Quantity.
        /// </summary>
        /// <value>The Quantity.</value>
        public virtual int Quantity
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets UnitPrice.
        /// </summary>
        /// <value>The UnitPrice.</value>
        public virtual decimal UnitPrice
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets AppliedVATRate.
        /// </summary>
        /// <value>The AppliedVATRate.</value>
        public virtual decimal AppliedVATRate
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets TotalPrice.
        /// </summary>
        /// <value>The TotalPrice.</value>
        public virtual decimal TotalPrice
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets VatTotal.
        /// </summary>
        /// <value>The VatTotal.</value>
        public virtual decimal VatTotal
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets AllTaxeIncludedTotal.
        /// </summary>
        /// <value>The AllTaxeIncludedTotal.</value>
        public virtual decimal AllTaxeIncludedTotal
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion

        #region Navigation Properties
        public virtual Order Order
        {
            get { return _order; }
            set
            {
                if (!ReferenceEquals(_order, value))
                {
                    var previousValue = _order;
                    _order = value;
                    FixupOrder(previousValue);
                }
            }
        }
        private Order _order;
        public virtual Product Product
        {
            get { return _product; }
            set
            {
                if (!ReferenceEquals(_product, value))
                {
                    var previousValue = _product;
                    _product = value;
                    FixupProduct(previousValue);
                }
            }
        }
        private Product _product;

        #endregion

        #region Association Fixup
    
        private void FixupOrder(Order previousValue)
        {
            if (previousValue != null && previousValue.OrderDetail.Contains(this))
            {
                previousValue.OrderDetail.Remove(this);
            }
    
            if (Order != null)
            {
                if (!Order.OrderDetail.Contains(this))
                {
                    Order.OrderDetail.Add(this);
                }
                if (FK_Order != Order.Id)
                {
                    FK_Order = Order.Id;
                }
            }
        }
    
        private void FixupProduct(Product previousValue)
        {
            if (previousValue != null && previousValue.OrderDetail.Contains(this))
            {
                previousValue.OrderDetail.Remove(this);
            }
    
            if (Product != null)
            {
                if (!Product.OrderDetail.Contains(this))
                {
                    Product.OrderDetail.Add(this);
                }
                if (FK_Product != Product.Id)
                {
                    FK_Product = Product.Id;
                }
            }
        }

        #endregion

    }
}
